import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2024-04-10
 * Time: 8:51
 */
public class Test {

    /*public static List func(String str1, String str2) {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < str1.length(); i++) {
            char ch = str1.charAt(i);
            if(!str2.contains(ch + "")) {
                list.add(ch + "");
            }
        }
        return list;
    }*/

    public static final String[] SUIT = {"♥", "♠", "♣", "♦"};
    
    public static List<Card> buyCard() {
        List<Card> ret = new ArrayList<>();
        for (int i = 0; i < SUIT.length; i++) {
            for (int j = 1; j <= 13; j++) {
                Card cards = new Card(SUIT[i], j);
                ret.add(cards);
            }
        }
        return ret;
    }

    public static void shuffle(List<Card> cards) {
        Random random = new Random();
        for (int i = cards.size()-1; i > 0; i--) {
            int j = random.nextInt(i);
            Card card = cards.get(i);
            cards.set(i,cards.get(j));
            cards.set(j,card);
        }
    }

    public static void main(String[] args) {
        //生成牌
        List<Card> cards = buyCard();
        System.out.println(cards);
        //洗牌
        shuffle(cards);
        System.out.println(cards);

        List<Card> hand1 = new ArrayList<>();
        List<Card> hand2 = new ArrayList<>();
        List<Card> hand3 = new ArrayList<>();
        List<List<Card>> hand = new ArrayList<>();
        hand.add(hand1);
        hand.add(hand2);
        hand.add(hand3);
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Card card = cards.remove(0);
                hand.get(j).add(card);
            }
        }

        System.out.println("第一个人的牌: ");
        System.out.println(hand1);
        System.out.println("第二个人的牌: ");
        System.out.println(hand2);
        System.out.println("第三个人的牌: ");
        System.out.println(hand3);

    }
    
    /*public static void main1(String[] args) {
        System.out.println(func("welcome to bit", "come"));
    }*/
}
